#pragma once
#include <osgViewer/Viewer>
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <glibmm.h>
#include <gdkmm.h>
#include <map>
#include <osgEarthUtil/EarthManipulator>
#include "airCraft.h"
namespace BJ
{



class mainView :
	public osgViewer::Viewer
{
public:
	mainView(osg::ArgumentParser & arg);
	void addPlane(double  Latitude,double longitude,double  Height ,double direction,double ancle);
private:
	sigc::connection  d_connection;
	void Init();
	void  EarthInit();
	void CameraInit();
	bool  AirCraftHeart();
	bool AirCraftTimer();
	void  GlibOpenThread();
	osg::ref_ptr<osgEarth::MapNode>  GetMap();
	osg::ref_ptr<osg::Group>     GetRoot();
	osg::ref_ptr<osg::PositionAttitudeTransform> pat;
	class GlibThreadRun:public OpenThreads::Thread
	{
	public:
		GlibThreadRun()
		{

		}

		~GlibThreadRun()
		{


		}
		void  run()
		{
			loop->run();

		}
		void stop()
		{
			loop->quit();

		}
		void setLoop(Glib::RefPtr<Glib::MainLoop> loop)
		{
 
			this->loop = loop;
		}
	private:
		Glib::RefPtr<Glib::MainLoop> loop;

	};
private:
	Glib::RefPtr<Glib::MainLoop> loop;
	GlibThreadRun  glibthread;
	osg::ref_ptr<osg::Group>  root;
	std::map<std::string,osg::ref_ptr<osg::Node>> namenode;
	osg::ref_ptr<osgEarth::Map>  map  ;
	osg::ref_ptr<osgEarth::MapNode>  mapnode;
	osg::ref_ptr<osgEarth::Util::EarthManipulator>  viewCamera;
	airCraft*  air;
  
protected:
	~mainView(void);
};

}